package com.snow.campuslink.user.facade;


import com.snow.campuslink.user.converter.dto.UpdateBbsPostActionCountDto;
import com.snow.campuslink.user.converter.dto.UpdateLostFoundActionCountDto;
import com.snow.campuslink.user.converter.dto.UpdateSecondHandActionCountDto;
import com.snow.campuslink.user.entity.UserComment;
import com.snow.campuslink.user.feign.BbsFeignService;
import com.snow.campuslink.user.feign.LostFoundFeignService;
import com.snow.campuslink.user.feign.SecondHandFeignService;
import com.snow.campuslink.user.service.IUserCommentService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author Gaosl
 * @ClassName UserBrowseFacade
 * @date 2021/2/22 14:47
 */
@Component
public class UserBrowseFacade {

    @Resource
    IUserCommentService userCommentService;

    @Resource
    BbsFeignService bbsFeignService;
    @Resource
    LostFoundFeignService lostFoundFeignService;
    @Resource
    SecondHandFeignService secondHandFeignService;

    public void saveComment(UserComment userComment) {
        userCommentService.save(userComment);
        switch (userComment.getModule()) {
            case "BBS_POST":
                bbsFeignService.updateActionCount( new UpdateBbsPostActionCountDto(userComment.getModuleId(),null,null,null,1));
                break;
            case "LOST_FOUND_POST":
                lostFoundFeignService.updateActionCount(new UpdateLostFoundActionCountDto(userComment.getModuleId(),null,null,null,1));
                break;
            case "SECOND_HAND_GOODS":
                secondHandFeignService.updateActionCount(new UpdateSecondHandActionCountDto(userComment.getModuleId(),null,null,null,1));
                break;
            default:
        }
    }
}
